#pragma once
#include "Object.h"

class GameScene;

class Tank:public MoveObject
{
public:
    Tank(float x,float y,float w,float h,Angle angle,float speed, GameScene* scene);
    virtual void Update(float dt) = 0;
    virtual void Render() = 0;
    inline bool isEnemy() const { return isEnemy_; }
    inline std::shared_ptr<Bullet> GetBullet() { return bullet_.lock(); }
protected:
    virtual void shoot() = 0;
    void Move(float dt);
    void moveLeft(float dt);
    void moveRight(float dt);
    void moveUp(float dt);
    void moveDown(float dt);
    void correctX();
    void correctY();

    bool checkCrashWithTerrain(SDL_Point (&crashPos)[2]);
    bool checkCrashWithOtherTanks(SDL_Point& otherPos);
    void checkCrashWithMargin();

    bool isRunning_;
    bool index_;
    bool isEnemy_;
    std::weak_ptr<Bullet> bullet_;
    GameScene* scene_;
    Angle prevAngle_;
};